<?php
session_start();
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.admin.php');
$admin=new admin();
$admin->canView($_SERVER['PHP_SELF']);

$namespace=$_FILES['theme'];
$tmp_name=$namespace['tmp_name'];
$theme_name=$namespace['name'];
$tn=explode(".",$theme_name);
//echo($tn[0]);
$t=$_SERVER['DOCUMENT_ROOT'].'/themes/'.$tn[0];
	mkdir($t,0777);
		 $zip = new ZipArchive;
     	$res = $zip->open($tmp_name);
     	$c=false;
	 if ($res === TRUE) {
         $zip->extractTo($t);
         $zip->close();
         $c=true;
	 } 
header("Location: /admin/");